package com.aaa.javaweb.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @Author Tian
 * @Date 2020/11/18
 */
//@WebFilter(filterName = "webDengLuFilter",value = {"/jiudianshow.jsp"})
public class WebDengLuFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("webdenglu登录初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        HttpServletRequest req=(HttpServletRequest)servletRequest;
        HttpServletResponse resp=(HttpServletResponse)servletResponse;
        HttpSession session = req.getSession();
        //String name = session.getAttribute("uname").toString();
//        if (name==null || name.equals("")){
//            resp.sendRedirect("/webdenglu.jsp");
//        }else {
//            req.setAttribute("name",name);
//            req.getRequestDispatcher("qianduan/jiudianshow.jsp").forward(servletRequest, servletResponse);
//            //filterChain.doFilter(servletRequest,servletResponse);
//        }
    }

    @Override
    public void destroy() {

    }
}
